<template>
  <div id="app"  class="counter-warp">

    <textarea v-model="remark" placeholder=""/>
    <span class="tips">提示：备注TOPIC业务用途，少于50个字符。</span>
    <a class="butclass" name="sure" @click="updateremark">更新</a>
    <mptoast />

  </div>
</template>

<script>
import { requestPost } from '@/utils/index'
import mptoast from 'mptoast'
export default {
  components: {
    mptoast
  },
  data () {
    return {
      remark: '',
      tid: 0
    }
  },
  onLoad (option) {
    this.remark = this.$root.$mp.query.remark
    this.tid = this.$root.$mp.query.id
    wx.setNavigationBarTitle({
      title: '更新 ' + this.$root.$mp.query.topicname + ' 备注'
    })
  },
  methods: {
    updateremark () {
      if (this.remark.trim().length > 50) {
        this.$mptoast('备注格式错误')
        return
      }
      var that = this
      var data = {
        "pageNo": "1",
        "rowCount": 30,
        "obj": {
          "remark": that.remark,
          "topicid": that.tid,
          "openid": wx.getStorageSync('openid'),
        }
      }
      requestPost(wx.getStorageSync('requestUrl') + '/wxsys/updateRemark', data, 'POST').then(function (value) {
        if (value.error_code === 0){
          that.$mptoast('备注修改成功')
        }
        console.log(value)
      }, function (value) {
        console.log(value)
      })
    }
  }
}
</script>

<style>
.tips{
  margin: 30px 20px auto;
  width: 90%;
  border: 0px solid rgba(206, 20, 20, 0.322);
  font-size: 16px;
  color: rgba(0, 0, 0, 0.500);
}
.counter-warp {
  margin-top: 2px;
}
textarea{
  border: 1px solid rgba(128, 128, 128, 0.322);
  margin: 30px auto;
  width: 90%;
  height: 200px;
}
.butclass{
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 24px;
  text-align: center;
  color: rgb(14, 14, 22);
  background-color: rgb(57,156,201);
  position: fixed;
  bottom: 0px;
}
</style>
